#ifndef CLIENTSOCKET_H
#define CLIENTSOCKET_H

#include <QTcpSocket>
#include "tunnel_mainwindow.h"
#include "chathandler.h"
#include "tunnel_struckts.h"

class ChatHandler;
class ClientSocket : public QTcpSocket
{
    Q_OBJECT

public:
    ClientSocket(QObject *parent = 0);
    virtual ~ClientSocket();

    bool fillPackage(Package *package, QDataStream *incommingStream);
    void sendPackage(Package *package);

    inline ChatHandler *getChatHandler() { return m_chatHandler; }

    void setLoginInformation(const QString loginName, const QString password);

private:
    quint16 dataSize;
    ChatHandler *m_chatHandler;
    QString m_loginName;
    QString m_password;

signals:
    void cSocketError(QString error);
    void changeLoginStatus(int progress, const QString &status);

private slots:
    void readSocket();
    void on_authCommand(QString arguments);

};


#endif // CLIENTSOCKET_H
